import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDStage {
	/**编号*/
	id,
	/**绝对关卡*/
	missionid,
	/**章节*/
	chapter,
	/**页数*/
	page,
	/**坐标点*/
	point,
	/**开启等级*/
	unlockLevel,
	/**该活动id开启时，该关卡才可以挑战*/
	checkActivityID,
	/**活动开启索引--等级100-255*/
	activityIndex,
	/**触发活动*/
	activityTigger,
	/**关卡类型--【1.主线】【2.爬塔】【3.随机事件关卡】【4.世界BOSS】【5.竞技场关卡】【6.军团讨伐】*/
	type,
	/**前置关卡*/
	preStage,
	/**关卡名称*/
	name,
	/**描述*/
	desc,
	/**掉落描述*/
	dropDesc,
	/**图标*/
	icon,
	/**场景*/
	scene,
	/**小怪数量*/
	monsterNum,
	/**小怪怪物ids*/
	monsters,
	/**boss怪物id*/
	boss,
	/**小怪掉落*/
	monsterReward,
	/**首领掉落*/
	bossReward,
	/**挂机经验产出--(每分钟)--StageGlobal[7]*/
	outputExp,
	/**挂机铜钱产出--(每分钟)--StageGlobal[8]*/
	outputGold,
	/**挂机银钢产出--(每分钟)--StageGlobal[9]*/
	outputStone,
	/**战力校验*/
	fightCheck,
	/**推荐战力*/
	fightNeed,
	/**是否需要广播--0无须，>0广播id*/
	message,
	/**自己增益buff*/
	selfSkills,
	/**怪物增益buff*/
	monsterSkills,
	/**扫荡奖励*/
	cleanReward,
	/**结束剧情*/
	storyEnd,
	/**开始剧情*/
	storyStart,

	/**枚举数量*/
	EnumCount
}



export class CDStage{
	/**编号*/
	public id: number;
	/**绝对关卡*/
	public missionid: number;
	/**章节*/
	public chapter: number;
	/**页数*/
	public page: number;
	/**坐标点*/
	public point: number;
	/**开启等级*/
	public unlockLevel: number;
	/**该活动id开启时，该关卡才可以挑战*/
	public checkActivityID: number;
	/**活动开启索引--等级100-255*/
	public activityIndex: number;
	/**触发活动*/
	public activityTigger: number;
	/**关卡类型--【1.主线】【2.爬塔】【3.随机事件关卡】【4.世界BOSS】【5.竞技场关卡】【6.军团讨伐】*/
	public type: number;
	/**前置关卡*/
	public preStage: number;
	/**关卡名称*/
	public name: number;
	/**描述*/
	public desc: number;
	/**掉落描述*/
	public dropDesc: number;
	/**图标*/
	public icon: string;
	/**场景*/
	public scene: string;
	/**小怪数量*/
	public monsterNum: number;
	/**小怪怪物ids*/
	public monsters: number[];
	/**boss怪物id*/
	public boss: number;
	/**小怪掉落*/
	public monsterReward: number;
	/**首领掉落*/
	public bossReward: number;
	/**挂机经验产出--(每分钟)--StageGlobal[7]*/
	public outputExp: number;
	/**挂机铜钱产出--(每分钟)--StageGlobal[8]*/
	public outputGold: number;
	/**挂机银钢产出--(每分钟)--StageGlobal[9]*/
	public outputStone: number;
	/**战力校验*/
	public fightCheck: number;
	/**推荐战力*/
	public fightNeed: number;
	/**是否需要广播--0无须，>0广播id*/
	public message: number;
	/**自己增益buff*/
	public selfSkills: number[];
	/**怪物增益buff*/
	public monsterSkills: number[];
	/**扫荡奖励*/
	public cleanReward: number;
	/**结束剧情*/
	public storyEnd: number;
	/**开始剧情*/
	public storyStart: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDStage.id: return this.id;
			case E_CDStage.missionid: return this.missionid;
			case E_CDStage.chapter: return this.chapter;
			case E_CDStage.page: return this.page;
			case E_CDStage.point: return this.point;
			case E_CDStage.unlockLevel: return this.unlockLevel;
			case E_CDStage.checkActivityID: return this.checkActivityID;
			case E_CDStage.activityIndex: return this.activityIndex;
			case E_CDStage.activityTigger: return this.activityTigger;
			case E_CDStage.type: return this.type;
			case E_CDStage.preStage: return this.preStage;
			case E_CDStage.name: return this.name;
			case E_CDStage.desc: return this.desc;
			case E_CDStage.dropDesc: return this.dropDesc;
			case E_CDStage.icon: return this.icon;
			case E_CDStage.scene: return this.scene;
			case E_CDStage.monsterNum: return this.monsterNum;
			case E_CDStage.monsters: return this.monsters;
			case E_CDStage.boss: return this.boss;
			case E_CDStage.monsterReward: return this.monsterReward;
			case E_CDStage.bossReward: return this.bossReward;
			case E_CDStage.outputExp: return this.outputExp;
			case E_CDStage.outputGold: return this.outputGold;
			case E_CDStage.outputStone: return this.outputStone;
			case E_CDStage.fightCheck: return this.fightCheck;
			case E_CDStage.fightNeed: return this.fightNeed;
			case E_CDStage.message: return this.message;
			case E_CDStage.selfSkills: return this.selfSkills;
			case E_CDStage.monsterSkills: return this.monsterSkills;
			case E_CDStage.cleanReward: return this.cleanReward;
			case E_CDStage.storyEnd: return this.storyEnd;
			case E_CDStage.storyStart: return this.storyStart;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDStage.id: this.id = v; break;
			case E_CDStage.missionid: this.missionid = v; break;
			case E_CDStage.chapter: this.chapter = v; break;
			case E_CDStage.page: this.page = v; break;
			case E_CDStage.point: this.point = v; break;
			case E_CDStage.unlockLevel: this.unlockLevel = v; break;
			case E_CDStage.checkActivityID: this.checkActivityID = v; break;
			case E_CDStage.activityIndex: this.activityIndex = v; break;
			case E_CDStage.activityTigger: this.activityTigger = v; break;
			case E_CDStage.type: this.type = v; break;
			case E_CDStage.preStage: this.preStage = v; break;
			case E_CDStage.name: this.name = v; break;
			case E_CDStage.desc: this.desc = v; break;
			case E_CDStage.dropDesc: this.dropDesc = v; break;
			case E_CDStage.icon: this.icon = v; break;
			case E_CDStage.scene: this.scene = v; break;
			case E_CDStage.monsterNum: this.monsterNum = v; break;
			case E_CDStage.monsters: this.monsters = v; break;
			case E_CDStage.boss: this.boss = v; break;
			case E_CDStage.monsterReward: this.monsterReward = v; break;
			case E_CDStage.bossReward: this.bossReward = v; break;
			case E_CDStage.outputExp: this.outputExp = v; break;
			case E_CDStage.outputGold: this.outputGold = v; break;
			case E_CDStage.outputStone: this.outputStone = v; break;
			case E_CDStage.fightCheck: this.fightCheck = v; break;
			case E_CDStage.fightNeed: this.fightNeed = v; break;
			case E_CDStage.message: this.message = v; break;
			case E_CDStage.selfSkills: this.selfSkills = v; break;
			case E_CDStage.monsterSkills: this.monsterSkills = v; break;
			case E_CDStage.cleanReward: this.cleanReward = v; break;
			case E_CDStage.storyEnd: this.storyEnd = v; break;
			case E_CDStage.storyStart: this.storyStart = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDStage> = new HashMap<number, CDStage>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDStage[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDStage();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].missionid = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].chapter = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].page = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].point = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].unlockLevel = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].checkActivityID = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].activityIndex = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].activityTigger = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].type = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].preStage = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dropDesc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].icon = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].scene = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].monsterNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].monsters = [];
			const attrArray = list[i].monsters;
			const arraySize = byte.readInt32();
			for (let j = 0; j < arraySize; j++) {
				attrArray[j] = byte.readInt32();
			}
		}
		for (i = 0; i < size; i++) {
			list[i].boss = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].monsterReward = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].bossReward = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].outputExp = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].outputGold = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].outputStone = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].fightCheck = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].fightNeed = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].message = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].selfSkills = [];
			const attrArray = list[i].selfSkills;
			const arraySize = byte.readInt32();
			for (let j = 0; j < arraySize; j++) {
				attrArray[j] = byte.readInt32();
			}
		}
		for (i = 0; i < size; i++) {
			list[i].monsterSkills = [];
			const attrArray = list[i].monsterSkills;
			const arraySize = byte.readInt32();
			for (let j = 0; j < arraySize; j++) {
				attrArray[j] = byte.readInt32();
			}
		}
		for (i = 0; i < size; i++) {
			list[i].cleanReward = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].storyEnd = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].storyStart = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDStage{
		return this.datas ? this.datas.get(id) : null;
	}
}
